package com.peak.distribution.web.validator.method;

import java.util.Map;

import org.springframework.beans.factory.annotation.Value;

import com.peak.distribution.web.validator.ValidateRuleMethod;
import com.peak.spring.boot.tools.Emptys;

/**
 * 必填，不能为空的校验
 * @author Haley Gao
 *
 */
public class Require implements ValidateRuleMethod {
	
	@Value("${validate.rule.require}")
	private String errorMessage;

	@Override
	public boolean execute(Object value) {
		return Emptys.isNotEmpty(value);
	}

	@Override
	public String getErrorMessageTemplate() {
		return Emptys.isEmpty(this.errorMessage) ? "{0}为必填内容" : this.errorMessage;
	}

	@Override
	public void setParams(Map<String, Object> param) {
		// 没啥可传的
	}

}
